<?php
include "../../Koneksi/koneksi.php";

$cekJumlah = mysql_query("select count(kodeKelas) 'jumlah' from kelas");
$cekKode=mysql_fetch_array($cekJumlah);
$kodeKelas = $cekKode['jumlah']+1;

$namaKelas = $_POST['kode'].$_POST['huruf'];
$namaKelas_Sekolah = $_POST['namaKelas_Sekolah'];


$cek = mysql_fetch_array(mysql_query("SELECT namaKelas FROM kelas WHERE namaKelas='$namaKelas'"));
if (empty($cek['namaKelas'])) {
    mysql_query("insert into kelas (kodeKelas, namaKelas, sekolah) value "
            . "('$kodeKelas' ,'$namaKelas' ,"
            . "1)");
    $result = header('location:../Form/FormKelas.php');
} else {
    ?>
    <script>alert("Kelas Sudah Pernah Diinputkan");
                    document.location.href = "../Form/FormKelas.php"</script>
    <?php
}

echo $result;
?>